package com.stylefeng.guns.modular.vpn_app_version.service.impl;

import com.stylefeng.guns.core.common.constant.DatasourceEnum;
import com.stylefeng.guns.core.common.exception.BizExceptionEnum;
import com.stylefeng.guns.core.exception.GunsException;
import com.stylefeng.guns.core.mutidatasource.annotion.DataSource;
import com.stylefeng.guns.modular.system.model.VpnAppVersion;
import com.stylefeng.guns.modular.system.dao.VpnAppVersionMapper;
import com.stylefeng.guns.modular.vpn.utils.LogUtil;
import com.stylefeng.guns.modular.vpn_app_version.service.IVpnAppVersionService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2020-03-14
 */
@Service
public class VpnAppVersionServiceImpl extends ServiceImpl<VpnAppVersionMapper, VpnAppVersion> implements IVpnAppVersionService {

    @Autowired
    private VpnAppVersionMapper appVersionMapper;

    @Override
    @DataSource(name = DatasourceEnum.DATA_SOURCE_BIZ)
    @Transactional
    public void addVersionInfo(VpnAppVersion vpnAppVersion) {

        //添加动作
        insert(vpnAppVersion);

        LogUtil.saveOperationLog("添加版本管理",
                "添加了一条版本管理信息, 版本号："+vpnAppVersion.getVersionNo());
//        VpnAppVersion appVersion = appVersionMapper.findLastVersionInfo();
//        if(vpnAppVersion.getVersionCode() > appVersion.getVersionCode()){
//            //添加的版本号大于现有最新版本号
//
//        }
//        else {
//            throw new GunsException(BizExceptionEnum.VPN_APP_VERSION_ADD_ERROR);
//        }
    }
}
